# -*- coding: utf-8 -*-

from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import sys


class MainWindow(QListWidget):

    def __init__(self):
        super(MainWindow, self).__init__()

        self.setWindowTitle("QListWidget示例")
        self.resize(300, 120)
        self.addItem("Item 1")
        self.addItem("Item 2")
        self.addItem("Item 3")
        self.addItem("Item 4")
        self.itemClicked.connect(self.clicked)

    def clicked(self, item):
        QMessageBox.information(self, "ListWidget", "你选择了：%s" % item.text())


if __name__ == '__main__':
    app = QApplication(sys.argv)
    win = MainWindow()
    win.show()
    sys.exit(app.exec())